package com.cadre.common.utils.oldutil;

import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;

import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: XuexiaoHandler.class */
public class XuexiaoHandler implements CellHandler {
    @Override // com.tdqy.cadre.modular.profess.common.report.CellHandler
    public void setValue(XWPFParagraph paragraph, Map data) {
        XWPFRun run = paragraph.createRun();
        CTBookmark bookmark = paragraph.getCTP().getBookmarkStartArray(0);
        if (data.get(bookmark.getName()) != null) {
            String value = data.get(bookmark.getName()).toString().trim();
            int row = bookmark.getName().equals("a01_a0814") ? 4 : 5;
            if (RenmbReportHelper.isBreak(value)) {
                ((XWPFTable) paragraph.getDocument().getTables().get(1)).getRow(row).getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                run.setFontSize(RenmbReportHelper.executeFontSize(value, initBiyeyuanxiaoConfig()));
                run.setText(value);
                return;
            }
            String[] values = RenmbReportHelper.splitstr(value);
            Map<Integer, Integer> tmap = initBiyeyuanxiaosignlConfig();
            int fontsize1 = RenmbReportHelper.executeFontSize(values[0], tmap);
            run.setFontSize(fontsize1);
            run.setText(values[0]);
            if (fontsize1 == 8 && NStringUtils.getWordCount(values[0]) > 40) {
                RenmbReportHelper.setSpacing(paragraph, "160");
            }
            XWPFParagraph p = ((XWPFTable) paragraph.getDocument().getTables().get(1)).getRow(row).getCell(4).addParagraph();
            int fontsize2 = RenmbReportHelper.executeFontSize(values[1], tmap);
            XWPFRun run1 = p.createRun();
            run1.setFontSize(fontsize2);
            run1.setText(values[1]);
            if (fontsize2 == 8 && NStringUtils.getWordCount(values[0]) > 40) {
                RenmbReportHelper.setSpacing(p, "160");
            }
        }
    }

    private static Map<Integer, Integer> initBiyeyuanxiaoConfig() {
        Map<Integer, Integer> map = new LinkedHashMap<>();
        map.put(46, 14);
        map.put(54, 12);
        map.put(70, 10);
        map.put(148, 8);
        return map;
    }

    private static Map<Integer, Integer> initBiyeyuanxiaosignlConfig() {
        Map<Integer, Integer> map = new LinkedHashMap<>();
        map.put(22, 14);
        map.put(26, 12);
        map.put(32, 10);
        map.put(80, 8);
        return map;
    }
}
